package com.kymatrix.mpo.plus.bpm.server.model.form.form;

import com.kymatrix.mpo.plus.bpm.server.model.entity.definition.BpmFormEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.time.LocalDateTime;
import java.util.List;
import javax.validation.constraints.NotNull;
import lombok.Data;
import lombok.experimental.Accessors;

@ApiModel(value = "管理后台 - 动态表单 Response")
@Data
@Accessors(chain=true)
public class BpmFormResp {

    @ApiModelProperty(value = "表单编号", example = "1024")
    private String id;

    @ApiModelProperty(value = "表单名称", example = "zhangsan")
    @NotNull(message = "表单名称不能为空")
    private String name;

    @ApiModelProperty(value = "表单的配置-JSON 字符串")
    @NotNull(message = "表单的配置不能为空")
    private String conf;

    @ApiModelProperty(value = "表单项的数组-JSON 字符串的数组")
    @NotNull(message = "表单项的数组不能为空")
    private List<String> fields;

    @ApiModelProperty(value = "表单状态 EnableType", example = "1")
    @NotNull(message = "表单状态不能为空")
    private String status; 

    @ApiModelProperty(value = "备注", example = "我是备注")
    private String remark;

    @ApiModelProperty(value = "创建时间")
    private LocalDateTime createTime;
    
    public static BpmFormResp fromEntity(BpmFormEntity entity) {
        if (entity == null) {
            return null;
        }
        BpmFormResp resp = new BpmFormResp();
        resp.setId(entity.getId());
        resp.setName(entity.getName());
        resp.setConf(entity.getConf());
        resp.setFields(entity.getFields());
        resp.setStatus(entity.getStatus());
        resp.setRemark(entity.getRemark());
        resp.setCreateTime(entity.getCreateTime());
        return resp;
    }

}
